package com.bmft.hello.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Jarvan
 * @version 1.0
 * @create 2020/11/4 17:44
 */
@Configuration
public class ElasticSearchConf {
    /**
     * Register Bean，use  "@Autowired" to call this
     * @return es client .
     * [问题，如何解决autowired为null]
     */
    @Bean
    RestHighLevelClient restHighLevelClient(){
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("localhost", 9200, "http")));
    }

}
